Skip to content

fix(feature-flags): preserve async readiness errors with a zero timeout - #787

Merged
gjtorikian merged 2 commits into
workos:mainfrom
pcbeingused33:fix/c7622-async-feature-flags-ready
Nov 30, 2026
Merged

gjtorikian merged 2 commits into
workos:mainfrom
pcbeingused33:fix/c7622-async-feature-flags-ready

Conversation

@pcbeingused33

Copy link
Copy Markdown
Contributor

Description

When the async feature flags runtime is closed before it becomes ready, it sets the readiness event to wake waiters. With timeout=0, asyncio.wait_for cancels the event wait before it can observe that signal, so the call raises TimeoutError instead of the documented RuntimeError. The same happens after polling stops on a 401: an immediate wait reports a timeout instead of the documented AuthenticationError, hiding an invalid API key.

Check whether the event is already set before waiting. The regression test covers immediate waits after closure, and the pending-configuration test verifies that an immediate wait still raises TimeoutError.

Documentation

[ ] Yes

AI assistance was used to prepare this change and its tests.

@pcbeingused33
pcbeingused33 requested a review from a team as a code owner November 30, 2026 20:03
@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Preserves readiness errors when an async feature flags client receives an immediate wait.

  • Async readiness waits preserve errors when the signal is already set.

Reviews (2) · Last reviewed commit: "test: add the zero timeout case to the 4..." · Reviewed by Greptile

@gjtorikian gjtorikian changed the title Preserve async feature flag readiness errors with a zero timeout fix(feature-flags): preserve async readiness errors with a zero timeout Nov 30, 2026
The test for the AuthenticationError used only a timeout of 1 second.
That case passed before the correction, so it could not find the defect
again. Run the test with timeouts of 0 and 1.
@gjtorikian
gjtorikian merged commit ff2006e into workos:main Nov 30, 2026
13 checks passed
@gjtorikian

Copy link
Copy Markdown
Contributor

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants